<?php


namespace app\common\model\mysql;


class SpecsValue extends BaseModel
{
    public function add($data) {
        $this->save($data);
        return $this->id;
    }
    /**
     * 根据规则ID 获取属性
     * @param $specsId
     * @return \think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public function getBySpecsId($specsId) {
        $where = [
            'specs_id' => $specsId,
            'status' => 1
        ];
        return $this->where($where)->select();
    }

    public function getNormalBySpecsId($specsId, $field="*") {
        $where = [
            "specs_id" => $specsId,
            "status" => 1,
        ];

        $res = $this->where($where)
            ->field($field)
            ->select();
        return $res;
    }
}